<!DOCTYPE html>
<html>
<body>
	<div id="container" style="width:100%">
		<!-- Header here -->
		<div id="header" style="background-color:#FFA500;">
			<h1 style="margin-bottom:0;text-align:center">Quản lý lịch học</h1>
		</div>
		
		<!--list of subjects here -->
		<div id="subjects" style="background-color:#FFD700;height:400px;width:35%;float:left;">
			<h2 style="margin-bottom:0;">Danh sách môn học</h2>
			<div style="width:90%; margin:auto">
			<ol>
				<?php foreach ($subjects as $subject):?>
					<li>
					<?php echo $this->Html->link($subject['Subject']['sub_name'], array('controller' => 'schedules', 'action' => 'schedule_index', $subject['Subject']['sub_id'])); ?>
					</li>
				<?php endforeach; ?>
				<?php unset($subject); ?>
			</ol>
			</div>
		</div>
		
		<!-- Schedule here -->
		<div id="schedules" style="background-color:#EEEEEE;height:400px;width:65%;float:left;">
			<div><h2 style="margin-bottom:0;">Lịch học</h2></div>
			<?php if ($subject_id == NULL){?> <!-- do nothing -->
			<?php } else {?>
				<?php $schedules = $this->requestAction('/schedules/schedulesFromSubIdGet', array('subject_id'=>$subject_id))?>
				<div style="overflow:auto;height:85%">
				<table style="width:100%;">
					<tr>
						<th width="10%">Id</th>
						<th width="35%">Thứ</th>
						<th width="20%">Bắt đầu</th>
						<th width="20%">Kết thúc</th>
						<th width="15%">Chỉnh sửa</th>
					</tr>
				
					<!-- For each schedule, show in a row of table -->
				    <?php foreach ($schedules as $schedule): ?>
				    <tr>
				        <td><?php echo $schedule['Schedule']['m_sdl_id']; ?></td>
				        <td><?php echo $weekdays[$schedule['Schedule']['m_sdl_week_day']]; ?></td>
				        <td><?php echo $schedule['Schedule']['m_sdl_start_hour']; ?></td>
				        <td><?php echo $schedule['Schedule']['m_sdl_end_hour']; ?></td>
				        <td>
				            <?php echo $this->Form->postLink('Xóa',
				            		                          array('action' => 'schedule_delete', $subject_id, $schedule['Schedule']['m_sdl_id']),
				                                              array('confirm' => 'Are you sure?'));?>
				            /
				            <?php echo $this->Html->link('Sửa', array('action' => 'schedule_edit', $subject_id, $schedule['Schedule']['m_sdl_id']));?>
				        </td>
				    </tr>
				    <?php endforeach; ?>
				    <?php unset($schedule); ?>
				</table>
				</div>
				<?php echo $this->Form->create('Schedule', array('style'=>'text-align:left'));?>
				<?php echo $this->Form->submit('Thêm Lịch Học', array('name'=>'gotoScheduleAdd')); ?>
				<?php echo $this->Form->end() ?>
			<?php }?>
		</div>
		
		<!-- Footer here -->
		<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;">
			Copyright © W3Schools.com
		</div>
	</div>
</body>
</html> 